Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add str conversions for types for JSON #313

Merged
merged 22 commits into from
Oct 24, 2023
Merged

Add str conversions for types for JSON #313

merged 22 commits into from
Oct 24, 2023

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Oct 21, 2023

What

Add str conversions for conversion to JSON for types that are naturally represented with SEP-23 Strkeys.

Example

Before

{
  "tx": {
    "tx": {
      "source_account": {
        "ed25519": "3cb361ab624b10704c6ccf4fdb1e4079d23d68ec2cd322c22834c41ae1e64bd3"
      },
      "fee": 0,
      "seq_num": 1,
      "cond": "none",
      "memo": {
        "text": "Stellar"
      },
      "operations": [
        {
          "source_account": {
            "ed25519": "9b9ffabacf4665b3572976fb850979cbc76b9d679c6bcaebd59bbfb343e8e946"
          },
          "body": {
            "change_trust": {
              "line": {
                "credit_alphanum4": {
                  "asset_code": "41424344",
                  "issuer": {
                    "public_key_type_ed25519": "43d09f492a2ae3aa0aed8ecedcb226a4f750a90ecb4e09f9ac764a5537cad877"
                  }
                }
              },
              "limit": 9223372036854775807
            }
          }
        }
      ],
      "ext": "v0"
    },
    "signatures": []
  }
}

After

{
  "tx": {
    "tx": {
      "source_account": "GA6LGYNLMJFRA4CMNTHU7WY6IB45EPLI5QWNGIWCFA2MIGXB4ZF5GQGY",
      "fee": 0,
      "seq_num": 1,
      "cond": "none",
      "memo": {
        "text": "Stellar"
      },
      "operations": [
        {
          "source_account": "GCNZ76V2Z5DGLM2XFF3PXBIJPHF4O245M6OGXSXL2WN37M2D5DUUNSOO",
          "body": {
            "change_trust": {
              "line": {
                "credit_alphanum4": {
                  "asset_code": "41424344",
                  "issuer": "GBB5BH2JFIVOHKQK5WHM5XFSE2SPOUFJB3FU4CPZVR3EUVJXZLMHOLOM"
                }
              },
              "limit": 9223372036854775807
            }
          }
        }
      ],
      "ext": "v0"
    },
    "signatures": []
  }
}

Why

So that the JSON generated for the XDR is as readable as possible. Folks are used to seeing addresses as Strkeys, not hex/hashes.

Close stellar/xdrgen#171

Dependent on stellar/xdrgen#177

src/curr/str.rs Outdated Show resolved Hide resolved
@leighmcculloch leighmcculloch marked this pull request as ready for review October 24, 2023 18:11
@leighmcculloch leighmcculloch added this pull request to the merge queue Oct 24, 2023
Merged via the queue into main with commit ae0b8bb Oct 24, 2023
7 checks passed
@leighmcculloch leighmcculloch deleted the str branch October 24, 2023 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants